package com.dingreading.cloud.soms.controller;

import com.dingreading.cloud.common.base.R;
import com.dingreading.cloud.common.util.PageUtil;
import com.dingreading.cloud.soms.service.CaLessonEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/front/caLessonEvaluate")
@Api(tags = "门店-课程评价管理")
public class FrontCaLessonEvaluateController {
    @Resource
    private CaLessonEvaluateService caLessonEvaluateService;

    @ApiOperation(value = "评价管理分页列表")
    @PostMapping(value = "/pageList")
    public R<Object> pageList(
            @ApiParam(value = "分页公共类") PageUtil pageUtil,
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "学生姓名/老师姓名") @RequestParam(value = "keyword", required = false) String keyword,
            @ApiParam(value = "活动服务uid") @RequestParam(value = "projectUid", required = false) String projectUid,
            @ApiParam(value = "活动开始日期") @RequestParam(value = "beginDate", required = false) String beginDate,
            @ApiParam(value = "活动结束日期") @RequestParam(value = "endDate", required = false) String endDate
    ) {
        R<Object> ret = caLessonEvaluateService.pageList(
                pageUtil, corpUid, storeUid, staffUid, staffName,
                keyword, projectUid, beginDate, endDate
        );
        return ret;
    }

    @ApiOperation(value = "获取当前评价")
    @PostMapping(value = "/getBean", produces = "application/json; charset=UTF-8")
    public R<Object> getBean(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "点名记录uid") @RequestParam(value = "callNamesUid") String callNamesUid
    ) {
        R<Object> result = caLessonEvaluateService.getBean(corpUid, storeUid, staffUid, staffName, callNamesUid);
        return result;
    }

    @ApiOperation(value = "教师评价学生")
    @PostMapping(value = "/teacherEvaluate", produces = "application/json; charset=UTF-8")
    public R<Object> teacherEvaluate(
            @ApiParam(value = "公司uid") @RequestParam(value = "corpUid") String corpUid,
            @ApiParam(value = "门店uid") @RequestParam(value = "storeUid") String storeUid,
            @ApiParam(value = "员工uid") @RequestParam(value = "staffUid") String staffUid,
            @ApiParam(value = "员工姓名") @RequestParam(value = "staffName") String staffName,
            @ApiParam(value = "点名记录uid") @RequestParam(value = "callNamesUid") String callNamesUid,
            @ApiParam(value = "老师给学生评分") @RequestParam(value = "teacherScore") Integer teacherScore,
            @ApiParam(value = "老师给学生评价") @RequestParam(value = "teacherComment", required = false) String teacherComment

    ) throws ParseException {
        R<Object> ret = caLessonEvaluateService.teacherEvaluate(
                corpUid, storeUid, staffUid, staffName, callNamesUid, teacherScore, teacherComment
        );
        return ret;
    }
}
